package com.xbfinance.portal.web;

import com.xbfinance.portal.pojo.po.P2pAccount;
import com.xbfinance.portal.pojo.po.P2pAccountBank;
import com.xbfinance.portal.pojo.po.P2pUser;
import com.xbfinance.portal.service.AccountBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Controller
public class AccountBankController {
    @Autowired
    AccountBankService accountBankService;

    @RequestMapping("/insertaccount")
    public String InsertAccount(P2pAccountBank p2pAccountBank, HttpSession session){
        P2pUser user = (P2pUser) session.getAttribute("user");
        if(user!=null){
            p2pAccountBank.setUserid(user.getUserid());
        }else {
            p2pAccountBank.setUserid(3);
        }
        Map<String,Object> map = new HashMap<>();
        map = accountBankService.InsertAccount(p2pAccountBank);
        return "/bankmanage_add_sucess";
    }
}
